<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/11/22
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        span {
            color: red;
        }
    </style>

</head>

<body class="form-wrap">

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">表单组合</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form id="f1" class="layui-form" action="${pageContext.request.contextPath}/user/updateUser.do"
                  lay-filter="component-form-group">

                <input type="hidden" name="userId" value="${user.userId}">
                <%--                用户名--%>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="un" name="userUsername" autocomplete="off"
                                   class="layui-input" value="${sessionScope.user.userUsername}">
                        </div>
                        <span id="uns"></span>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input type="password" id="pwd" name="userPassword" lay-verify="pass" placeholder="请输入密码"
                                   autocomplete="off"
                                   class="layui-input" value="${sessionScope.user.userPassword}">

                        </div>
                        <span id="pwds"></span>
                        <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">确认密码</label>
                        <div class="layui-input-inline">
                            <input type="password" id="repwd" name="userPassword" lay-verify="pass"
                                   placeholder="请输入确认密码"
                                   autocomplete="off"
                                   class="layui-input" value="">

                        </div>
                        <span id="repwds"></span>
                        <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">真实姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="userFullname" autocomplete="off"
                                   class="layui-input" value="${sessionScope.user.userFullname}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">手机号码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="userPhone" autocomplete="off"
                                   class="layui-input" value="${sessionScope.user.userPhone}">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">性别</label>
                        <c:if test="${sessionScope.user.userGender == '男'}">
                            <input type="radio" name="userGender" value="男" title="男" checked="">
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                    class="layui-anim layui-icon"></i>
                                <div>男</div>
                            </div>
                            <input type="radio" name="userGender" value="女" title="女">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>女</div>
                            </div>
                        </c:if>
                        <c:if test="${sessionScope.user.userGender == '女'}">
                            <input type="radio" name="userGender" value="男" title="男">
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                    class="layui-anim layui-icon"></i>
                                <div>男</div>
                            </div>
                            <input type="radio" name="userGender" value="女" title="女" checked="">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>女</div>
                            </div>
                        </c:if>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">年龄</label>
                        <div class="layui-input-inline">
                            <select name="userAge" lay-verify="required" lay-search="">
                                <option value="">请选择年龄</option>
                                <c:forEach var="age" begin="1" end="100">
                                    <option value="${age}" ${sessionScope.user.userAge == age?'selected=selected':''}>${age}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">住址</label>
                    <div class="layui-input-block">
                        <input type="text" name="userAddress" lay-verify="title" autocomplete="off"
                               placeholder="请输入详细地址"
                               class="layui-input" value="${sessionScope.user.userAddress}">
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button onclick="sub()" class="layui-btn" lay-submit="" lay-filter="component-form-demo1"
                                    type="button">修改
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>

                <%--                    范围--%>
                <%--                <div class="layui-form-item">--%>
                <%--                    <div class="layui-inline">--%>
                <%--                        <label class="layui-form-label">范围</label>--%>
                <%--                        <div class="layui-input-inline" style="width: 100px;">--%>
                <%--                            <input type="text" name="price_min" placeholder="￥" autocomplete="off" class="layui-input">--%>
                <%--                        </div>--%>
                <%--                        <div class="layui-form-mid">-</div>--%>
                <%--                        <div class="layui-input-inline" style="width: 100px;">--%>
                <%--                            <input type="text" name="price_max" placeholder="￥" autocomplete="off" class="layui-input">--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                </div>--%>


                <%--                    地址联动--%>
                <%--                <div class="layui-form-item">--%>
                <%--                    <label class="layui-form-label">联动选择框</label>--%>
                <%--                    <div class="layui-input-block">--%>
                <%--                        <div class="layui-inline">--%>
                <%--                            <select name="quiz1">--%>
                <%--                                <option value="">请选择省</option>--%>
                <%--                                <option value="浙江" selected="">浙江省</option>--%>
                <%--                                <option value="你的工号">江西省</option>--%>
                <%--                                <option value="你最喜欢的老师">福建省</option>--%>
                <%--                            </select>--%>
                <%--                            <div class="layui-unselect layui-form-select">--%>
                <%--                                <div class="layui-select-title"><input type="text" placeholder="请选择省" value="浙江省"--%>
                <%--                                                                       readonly class="layui-input layui-unselect"><i--%>
                <%--                                        class="layui-edge"></i></div>--%>
                <%--                                <dl class="layui-anim layui-anim-upbit">--%>
                <%--                                    <dd lay-value="" class="layui-select-tips">请选择省</dd>--%>
                <%--                                    <dd lay-value="浙江" class="layui-this">浙江省</dd>--%>
                <%--                                    <dd lay-value="你的工号" class="">江西省</dd>--%>
                <%--                                    <dd lay-value="你最喜欢的老师" class="">福建省</dd>--%>
                <%--                                </dl>--%>
                <%--                            </div>--%>
                <%--                        </div>--%>
                <%--                        <div class="layui-inline">--%>
                <%--                            <select name="quiz2">--%>
                <%--                                <option value="">请选择市</option>--%>
                <%--                                <option value="杭州">杭州</option>--%>
                <%--                                <option value="宁波" disabled="">宁波</option>--%>
                <%--                                <option value="温州">温州</option>--%>
                <%--                                <option value="温州">台州</option>--%>
                <%--                                <option value="温州">绍兴</option>--%>
                <%--                            </select>--%>
                <%--                            <div class="layui-unselect layui-form-select">--%>
                <%--                                <div class="layui-select-title"><input type="text" placeholder="请选择市" value="" readonly--%>
                <%--                                                                       class="layui-input layui-unselect"><i--%>
                <%--                                        class="layui-edge"></i></div>--%>
                <%--                                <dl class="layui-anim layui-anim-upbit">--%>
                <%--                                    <dd lay-value="" class="layui-select-tips">请选择市</dd>--%>
                <%--                                    <dd lay-value="杭州" class="">杭州</dd>--%>
                <%--                                    <dd lay-value="宁波" class=" layui-disabled">宁波</dd>--%>
                <%--                                    <dd lay-value="温州" class="">温州</dd>--%>
                <%--                                    <dd lay-value="温州" class="">台州</dd>--%>
                <%--                                    <dd lay-value="温州" class="">绍兴</dd>--%>
                <%--                                </dl>--%>
                <%--                            </div>--%>
                <%--                        </div>--%>
                <%--                        <div class="layui-inline">--%>
                <%--                            <select name="quiz3">--%>
                <%--                                <option value="">请选择县/区</option>--%>
                <%--                                <option value="西湖区">西湖区</option>--%>
                <%--                                <option value="余杭区">余杭区</option>--%>
                <%--                                <option value="拱墅区">临安市</option>--%>
                <%--                            </select>--%>
                <%--                            <div class="layui-unselect layui-form-select">--%>
                <%--                                <div class="layui-select-title"><input type="text" placeholder="请选择县/区" value=""--%>
                <%--                                                                       readonly class="layui-input layui-unselect"><i--%>
                <%--                                        class="layui-edge"></i></div>--%>
                <%--                                <dl class="layui-anim layui-anim-upbit">--%>
                <%--                                    <dd lay-value="" class="layui-select-tips">请选择县/区</dd>--%>
                <%--                                    <dd lay-value="西湖区" class="">西湖区</dd>--%>
                <%--                                    <dd lay-value="余杭区" class="">余杭区</dd>--%>
                <%--                                    <dd lay-value="拱墅区" class="">临安市</dd>--%>
                <%--                                </dl>--%>
                <%--                            </div>--%>
                <%--                        </div>--%>
                <%--                        <div class="layui-inline">--%>
                <%--                            <div class="layui-form-mid layui-word-aux">此处只是演示联动排版，并未做联动交互</div>--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                </div>--%>

                <%--                    复选框--%>
                <%--                <div class="layui-form-item">--%>
                <%--                    <label class="layui-form-label">复选框</label>--%>
                <%--                    <div class="layui-input-block">--%>
                <%--                        <input type="checkbox" name="like[write]" title="写作">--%>
                <%--                        <div class="layui-unselect layui-form-checkbox"><span>写作</span><i--%>
                <%--                                class="layui-icon layui-icon-ok"></i></div>--%>
                <%--                        <input type="checkbox" name="like[read]" title="阅读" checked="">--%>
                <%--                        <div class="layui-unselect layui-form-checkbox layui-form-checked"><span>阅读</span><i--%>
                <%--                                class="layui-icon layui-icon-ok"></i></div>--%>
                <%--                        <input type="checkbox" name="like[game]" title="游戏">--%>
                <%--                        <div class="layui-unselect layui-form-checkbox"><span>游戏</span><i--%>
                <%--                                class="layui-icon layui-icon-ok"></i></div>--%>
                <%--                    </div>--%>
                <%--                </div>--%>

                <%--                    开关--%>
                <%--                <div class="layui-form-item">--%>
                <%--                    <label class="layui-form-label">开关-默认关</label>--%>
                <%--                    <div class="layui-input-block">--%>
                <%--                        <input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF">--%>
                <%--                        <div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>OFF</em><i></i></div>--%>
                <%--                    </div>--%>
                <%--                </div>--%>

                <%--                    文本域--%>
                <%--                <div class="layui-form-item layui-form-text">--%>
                <%--                    <label class="layui-form-label">普通文本域</label>--%>
                <%--                    <div class="layui-input-block">--%>
                <%--                        <textarea name="text" placeholder="请输入内容" class="layui-textarea"></textarea>--%>
                <%--                    </div>--%>
                <%--                </div>--%>

            </form>
        </div>
    </div>
</div>


<script>
    <%--layui.config({--%>
    <%--    base: '${pageContext.request.contextPath}/static/${pageContext.request.contextPath}/static/${pageContext.request.contextPath}/static/layuiadmin/' //静态资源所在路径--%>
    <%--}).extend({--%>
    <%--    index: 'lib/index' //主入口模块--%>
    <%--}).use(['index', 'form', 'laydate'], function () {--%>
    <%--    var $ = layui.$--%>
    <%--        , admin = layui.admin--%>
    <%--        , element = layui.element--%>
    <%--        , layer = layui.layer--%>
    <%--        , laydate = layui.laydate--%>
    <%--        , form = layui.form;--%>

    <%--    form.render(null, 'component-form-group');--%>

    <%--    laydate.render({--%>
    <%--        elem: '#LAY-component-form-group-date'--%>
    <%--    });--%>

    <%--    /* 自定义验证规则 */--%>
    <%--    form.verify({--%>
    <%--        title: function (value) {--%>
    <%--            if (value.length < 5) {--%>
    <%--                return '标题至少得5个字符啊';--%>
    <%--            }--%>
    <%--        }--%>
    <%--        , pass: [/(.+){6,12}$/, '密码必须6到12位']--%>
    <%--        , content: function (value) {--%>
    <%--            layedit.sync(editIndex);--%>
    <%--        }--%>
    <%--    });--%>

    <%--    /* 监听指定开关 */--%>
    <%--    form.on('switch(component-form-switchTest)', function (data) {--%>
    <%--        layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {--%>
    <%--            offset: '6px'--%>
    <%--        });--%>
    <%--        layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)--%>
    <%--    });--%>

    <%--    /* 监听提交 */--%>
    <%--    form.on('submit(component-form-demo1)', function (data) {--%>
    <%--        parent.layer.alert(JSON.stringify(data.field), {--%>
    <%--            title: '最终的提交信息'--%>
    <%--        })--%>
    <%--        return false;--%>
    <%--    });--%>
    <%--});--%>


    var userflag = false;
    var passflag = false;
    var repassflag = false;

    $("#un").blur(function () {
        var username = $("#un").val();
        if (username == null || username.trim() == "") {
            $("#uns").text("用户名不能为空")
        } else if (username =='${sessionScope.user.userUsername}') {
            $("#uns").text("√")
            userflag = true;
        } else {
            var ajax = new XMLHttpRequest();
            ajax.open("get", "${pageContext.request.contextPath}/user/checkUsername.do?userUsername=" + username, true);

            ajax.send(null);

            ajax.onreadystatechange = function () {

                if (ajax.readyState === 4) {

                    var str = ajax.responseText;

                    if (str === "OK") {
                        $("#uns").text("√")
                        userflag = true;
                    } else if (str === "ERROR") {
                        $("#uns").text("用户名已存在")
                        userflag = false;
                    }
                }
            }
        }
    })

    $("#pwd").blur(function () {
        var password = $("#pwd").val()
        var span = $("#pwds");
        // trim去掉字符串两边的空格
        if (password == null || password.trim() == "") {
            // innerHTML定义标签的文本内容
            span.text("密码不能为空")
        } else {
            if (password.length < 6 || password.length > 14) {
                span.text("密码长度必须在6-14位之间")
            } else {
                span.text("√")
                passflag = true;
            }
        }
    });

    $("#repwd").blur(function () {
        var repassword = $("#repwd").val();
        var password = $("#pwd").val();
        var span = $("#repwds");
        // trim去掉字符串两边的空格
        if (repassword == null || repassword.trim() == "") {
            // innerHTML定义标签的文本内容
            span.text("确认密码不能为空")
        } else {
            if (repassword == password) {
                span.text("√")
                repassflag = true;
            } else {
                span.text("两次密码输入不一致")
            }
        }
    });


    function sub() {
        if (userflag && passflag && repassflag) {
            if (confirm("确认要进行注册吗？")) {
                $("#f1").submit()
            } else {
                alert("已取消")
            }
        } else {
            alert("输入有误！请核实用户名、密码、确认密码格式输入是否正确");
        }
    }

</script>


<style id="LAY_layadmin_theme">.layui-side-menu, .layadmin-pagetabs .layui-tab-title li:after, .layadmin-pagetabs .layui-tab-title li.layui-this:after, .layui-layer-admin .layui-layer-title, .layadmin-side-shrink .layui-side-menu .layui-nav > .layui-nav-item > .layui-nav-child {
    background-color: #20222A !important;
}

.layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a {
    background-color: #009688 !important;
}

.layui-layout-admin .layui-logo {
    background-color: #20222A !important;
}</style>
</body>


</html>
